def d(x):
    kd = 0
    for j in range(2,x):
        if x%j == 0:
            kd += 1
            break
    if kd == 0:
        return x
    else:
        return 0

print('введите слова через пробел')
q = list(map(str,input().split()))
w = ''
num = ['zero','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for i in q:
    for j in range(len(num)):
        if i == num[j]:
            w += str(j)
a = 10000000000
b = 10000000000
if len(w)!= 3:
    print('wrong input')
elif int(w) == d(int(w)):
    print(w)
else:
    for i in range(int(w)-20,int(w)+20):
        e = int(w)-int(d(i))
        if e>0:
            a = min(a,e)
        else:
            b = min(b,e)
    if abs(a) < abs(b):
        print(int(w) - a)
    else:
        print(int(w) + abs(b))
